package com.czl.module_user.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.czl.base.binding.command.BindingCommand
import com.czl.base.binding.command.BindingConsumer
import com.czl.base.data.bean.AddRecordBean
import com.czl.base.data.bean.MonthCardListBean
import com.czl.base.data.bean.RepairBean
import com.czl.module_user.R
import com.czl.module_user.databinding.ItemAddRecordBinding
import com.czl.module_user.fragment.AddRecordsFragment

/**
 *
 * @Description:
 * @Author: XCH
 * @CreateDate: 2021/12/10 11:38
 */
class AddRecordsAdapter(private val fragment: AddRecordsFragment) :
    BaseQuickAdapter<AddRecordBean, BaseDataBindingHolder<ItemAddRecordBinding>>(
        R.layout.item_add_record
    ) {

    override fun convert(
        holder: BaseDataBindingHolder<ItemAddRecordBinding>,
        item: AddRecordBean
    ) {
        holder.dataBinding?.apply {
            data = item
            adapter = this@AddRecordsAdapter
            executePendingBindings()
        }
    }

    val onRenewClick: BindingCommand<Any> = BindingCommand(BindingConsumer {
        if (it is AddRecordBean) {
            fragment.viewModel.uc.renewEvent.postValue(it)
        }
    })

    val onDeleteClick: BindingCommand<Any> = BindingCommand(BindingConsumer {
        if (it is AddRecordBean) {
            fragment.viewModel.uc.deleteEvent.postValue(it.id)
        }
    })

    fun getPersonType(type: Int): String {
        //"户主" "家庭成员", "租客", "朋友"
        return when (type) {
            1 -> "户主"
            2 -> "家庭成员"
            3 -> "租客"
            4 -> "朋友"
            else -> "未知"
        }
    }

    fun getApplyStatus(applyStatus: Int):String{
        //1:待审核,2:审核通过,3:审核不通过
        return when(applyStatus){
            1 -> "待审核"
            2 -> "已审核"
            3 -> "已驳回"
            else -> ""
        }
    }
}